import os
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack

from message.routing import message_websocket_urlpatterns
from job.routing import job_websocket_urlpatterns

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'boss.settings')

application = ProtocolTypeRouter({
    "http": get_asgi_application(),
    "websocket": AuthMiddlewareStack(
        URLRouter(
            message_websocket_urlpatterns + job_websocket_urlpatterns
        )
    ),
})